﻿<Window x:Class="MusicServer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:extra="clr-namespace:WPFImageWindows;assembly=WPFImageWindows"
        Title="Music Server" Height="203" Width="886"
        Loaded="UserControl_Loaded" AllowDrop="True">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="99*" />
        </Grid.RowDefinitions>
        
        <!--<extra:AudioViewerControl x:Name="OurAudioViewer" Width="100" HorizontalAlignment="Left" Grid.RowSpan="2" />-->


        <Grid Grid.Row="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="300*" />
                <ColumnDefinition Width="300*" />
            </Grid.ColumnDefinitions>
            
            <GridSplitter ResizeDirection="Columns" Width="5" HorizontalAlignment="Right"  />

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                    <RowDefinition Height="74*" />
                </Grid.RowDefinitions>

                
                <StackPanel Orientation="Horizontal" Margin="0,0,6,0">
                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonQueueSong" Click="ButtonQueueSong_Click" Grid.Row="0" Grid.Column="2" ToolTip="Add song to queue" >
                        <Image Source="Images\document - copy.png" />
                    </Button>

                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonRemoveItemFromPlaylist" Click="ButtonRemoveItemFromPlaylist_Click"  ToolTip="Remove Item From Playlist" >
                        <Image Source="Images\trash.png" />
                    </Button>
                    
                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonOpenPlaylist" Click="ButtonOpenPlaylist_Click"  ToolTip="Open Playlist" >
                        <Image Source="Images\file.png" />
                    </Button>
                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonSavePlaylist" Click="ButtonSavePlaylist_Click"  ToolTip="Save Playlist" >
                        <Rectangle Fill="{DynamicResource Software}" Width="20" Height="20"/>
                    </Button>

                    
                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonRandom100" Click="ButtonRandom100_Click" Grid.Row="0" Grid.Column="3" ToolTip="Enqueue 100 random songs" >
                        <Image Source="Images\file - copy.png" />
                    </Button>

                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonPrevious" ToolTip="Skip to the previous" Click="ButtonPrevious_Click"  >
                        <Image Source="Images\player - skipbackwards.png" />
                    </Button>
                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonNext" ToolTip="Skip to the next song in the queue" Click="ButtonNext_Click" Grid.Row="0" Grid.Column="1" >
                        <Image Source="Images\player - skipforward.png" />
                    </Button>

                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" ToolTip="Pause" x:Name="ButtonPause" Click="ButtonPause_Click" Grid.Row="0" Visibility="Hidden" Grid.Column="2" >
                        <Image Source="Images\player - pause.png" />
                    </Button>

                    <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonDeleteQueue" Click="ButtonDeleteQueue_Click" Grid.Row="0" Background="{x:Null}" BorderBrush="{x:Null}" Grid.Column="4" ToolTip="Clear the queue" >
                        <Image Source="Images\trash.png" />
                    </Button>
                    <TextBlock x:Name="TextBlockNowPlaying" Grid.Row="1" Grid.ColumnSpan="7" Text="{Binding Path=CurrentTrackFileOnly}" />
                    <TextBlock x:Name="TextBlockNext" Grid.Row="2" FontSize="8" Grid.ColumnSpan="7" Text="{Binding Path=NextTrack}" />

                    <Slider x:Name="SliderSongVolume" Grid.Column="5" Orientation="Horizontal" Minimum="0" Maximum="2" Width="100" Margin="10,0,0,0"
                Value="{Binding Path=SourceAmplitudeMultiplier,Mode=TwoWay}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Stretch" />

                    <CheckBox x:Name="CheckBoxLoop" Grid.Row="3" Grid.ColumnSpan="2" IsChecked="{Binding Path=Loop}" VerticalAlignment="Center" ToolTip="Loop all songs in the queue">Loop</CheckBox>
                    <TextBlock x:Name="TextBoxProgress" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="5"></TextBlock>
                </StackPanel>

                <ListView x:Name="ListViewPlayList" Grid.Row="1" AllowDrop="True" DragEnter="ListViewPlayList_DragEnter" Drop="ListViewPlayList_Drop" Margin="0,0,6,0" MouseDoubleClick="ListViewPlayList_MouseDoubleClick" SelectionMode="Single">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="Song" Width="150" DisplayMemberBinding="{Binding Name}"/>
                            <GridViewColumn Header="Artist" Width="150"  DisplayMemberBinding="{Binding Artist}"/>
                            <GridViewColumn Header="Length" Width="150"  DisplayMemberBinding="{Binding Duration}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Grid>
            
            
            <ListView x:Name="ListViewAudioSessions" Margin="5" Grid.Column="1">
            <ListView.View>
                <GridView>
                   
                    <GridViewColumn Header="Remote User" Width="180"  >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding RosterItem.Avatar}" Width="64" Height="64" />
                                    <StackPanel Orientation="Vertical">
                                        <Label FontSize="10" VerticalAlignment="Center" FontWeight="Bold" Content="{Binding RemoteJID}" />
                                        <Label FontSize="8" VerticalAlignment="Center" Content="{Binding CallDuration}" />
                                        <Label FontSize="8" VerticalAlignment="Center" Content="{Binding RemoteEndpoint}" />
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="State" Width="100" DisplayMemberBinding="{Binding SessionState}" />
                  
                    <GridViewColumn Header="Actions" Width="320">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Button Background="#AACCFFCC"  Height="32" Width="32" BorderBrush="{x:Null}" x:Name="ButtonClose" Click="ButtonClose_Click_1"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                        <Image Width="28" Height="28" Source="Images/connected.png" />
                                    </Button>
                                    <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Disconnect"/>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>

        </ListView>
        </Grid>

        <StackPanel Orientation="Horizontal">

            <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonPlaySong" HorizontalContentAlignment="Center"  VerticalContentAlignment="Center" Click="ButtonPlay_Click">
                <Image>
                    <Image.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsSourceActive}" Value="True">
                                    <Setter Property="Image.Source" Value="Images/Stop.png" />
                                    <Setter Property="Image.ToolTip" Value="Stop playing songs in queue" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsSourceActive}" Value="False">
                                    <Setter Property="Image.Source" Value="Images/play.png" />
                                    <Setter Property="Image.ToolTip" Value="Start playing songs in queue" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </Button>

            <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonConnect" HorizontalContentAlignment="Center"  VerticalContentAlignment="Center" Click="ButtonConnect_Click" >
                <Border Width="32" Height="32">
                    <Border.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Ready}" Value="False">
                                    <Setter Property="Border.Background" Value="{DynamicResource disconnected}" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Ready}" Value="True">
                                    <Setter Property="Border.Background" Value="{DynamicResource connected}" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>
            </Button>
            <Label x:Name="LabelPlaying" Content="{Binding CurrentTrack}" />
        </StackPanel>



    </Grid>
</Window>
